package com.drools.project.ruleService;

import com.drools.project.model.coupon.User;
import jakarta.annotation.Resource;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.springframework.stereotype.Service;

/**
 * 优惠券服务
 */
@Service
public class CouponService {

    @Resource
    private KieContainer kieContainer;

    public void applyCoupons(User user) {
        KieSession kieSession = kieContainer.newKieSession();
        kieSession.insert(user);
        kieSession.fireAllRules();
        kieSession.dispose();
    }
}
